// pages/lesson/lesson.json.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 页面总高度将会放在这里
    windowHeight: 0,
    // scroll-view的高度
    swiperViewHeight: 0,
    TabCur: 0,
    scrollLeft: 0,
    scrollTop: 0,
    lessonList: [
      // '概览',
      "Scratch", "Python", "C/C++", "CSP/NOIP"
    ]
  },
  tabSelect(e) {
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id - 1) * 60,
    })
    wx.pageScrollTo({
      scrollTop: 0,
    })
  },
  swiperChange: function (e) {

    var radio = this.data.radio
    var current = e.detail.current
    var swiperViewHeight = 0
    if (current == 0) {
      swiperViewHeight = 4350 * radio
    } else if (current == 1) {
      swiperViewHeight = 3354 * radio
    } else if (current == 2) {
      swiperViewHeight = 2935 * radio
    } else if (current == 3) {
      swiperViewHeight = 2655 * radio
    } else if (current == 4) {
      swiperViewHeight = 2355 * radio
    }
    this.setData({
      TabCur: current,
      swiperViewHeight: swiperViewHeight
    })

  },

  previewImage: function (e) {
    wx.previewImage({
      current: 'http://ww4.sinaimg.cn/large/006tNc79ly1g4pucxqr7zj30by0by3yp.jpg', // 当前显示图片的http链接  
      urls: ['http://ww4.sinaimg.cn/large/006tNc79ly1g4pucxqr7zj30by0by3yp.jpg'] // 需要预览的图片http链接列表  
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    /** 
     * 获取系统信息,系统宽高
     */
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight / 100,
          radio: 750 / res.windowWidth,
          swiperViewHeight: 750 / res.windowWidth * 4350
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function (e) {
    var that = this;

    that.setData({
      currentTab: 10,
      currentC: 0
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
      })
    }
  },
  clickC: function (e) {
    var that = this;
    if (this.data.currentC === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentC: e.target.dataset.current,
      })
    }
  }
})